﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PagedList<Web.Model.User>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Index</h2>

<div class="container">
    <div class="lead column last span-24">
        <h2>Web.Model.User</h2>
    </div>
    <div class="column">
    <table>
        <tr>
            <th></th>
            <th>
                UserName
            </th>
            <th>
                LastLogin
            </th>
            <th>
                CreatedOn
            </th>
            <th>
                Friendly
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.ID }) %> |
                <%= Html.ActionLink("Details", "Details", new { id = item.ID })%> |
            </td>
            <td>
                <%= Html.Encode(item.UserName) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.LastLogin)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.CreatedOn)) %>
            </td>
            <td>
                <%= Html.Encode(item.Friendly) %>
            </td>
        </tr>
    
    <% } %>

        <tr>
            <td colspan="7" class="pager">
                <%
                int currentPage = Model.PageIndex;
                int totalPages=Model.TotalPages;
                %>
                <form action="<%=Url.Action("index") %>" method="post" id="pagerForm">
                    
                    <input type="hidden" name="pg" value="<%=currentPage %>" />
                    <%if (currentPage == 1) { %>
                    <img src="/public/images/control_start.png" style="cursor:hand" />
                    <img src="/public/images/control_rewind.png" style="cursor:hand"/>
                    <%} else { %>
                    <img src="/public/images/control_start_blue.png" style="cursor:hand" onclick="pg.value='1';submitPager();"/>
                    <img src="/public/images/control_rewind_blue.png" style="cursor:hand" onclick="pg.value='<%=currentPage-1%>';submitPager();""/>
                    <%} %>
                    
                    <select onchange="pg.value=this.options[this.selectedIndex].value;submitPager();"" name="ddpager">
                        <%for (int i = 1; i <= totalPages; i++) { %>
                            <option <%if(currentPage==i){ %>selected="true"<%}%> value="<%=i%>"><%=i%></option>
                        <%} %>
                    </select>

                    <%if (currentPage == totalPages) { %>
                    <img src="/public/images/control_fastforward.png" style="cursor:hand" />
                    <img src="/public/images/control_end.png" style="cursor:hand" />
                    <%} else { %>
                    <img src="/public/images/control_fastforward_blue.png" style="cursor:hand" onclick="pg.value='<%=currentPage+1%>';submitPager();""/>
                    <img src="/public/images/control_end_blue.png" style="cursor:hand" onclick="pg.value='<%=totalPages%>';submitPager();""/>
                    <%} %>
               </form>          
            </td>
        </tr>


    </table>

    <p>
        <%= Html.ActionLink("Create New", "Create") %>
    </p>
    </div>
  </div>

</asp:Content>

